# -*- coding: utf-8 -*-
# @Time    : 2024/9/5 20:48
# @Author  : 荒
# @FileName: encrypt.py
# @Software: PyCharm
import hashlib
import uuid
from django.conf import settings

def md5(string):
    """ MD5加密 """
    # hash_object = hashlib.md5('9bo^2^sgl6zpy&@v^4k#q9s#@-hsjkdecnefj(wjt2#tud+o%l'.encode('utf-8'))
    hash_object = hashlib.md5(settings.SECRET_KEY.encode('utf-8'))
    hash_object.update(string.encode('utf-8'))
    return hash_object.hexdigest()


def uid(string):
    data = "{}-{}".format(str(uuid.uuid4()),string)
    return md5(data)
# if __name__ == '__main__':
#     str = "123"
#     print(md5(str))